<script lang="ts" setup>
import { defineProps, shallowRef, computed, onMounted } from 'vue';
const props = defineProps({
    name: {
        type: String,
        required: true
    },
    width:{
        type: [Number, String],
        default: 24
    },
    height:{
        type: [Number, String],
        default: 24
    },
    color:{
        type: String,
        default: 'currentColor'
    }
})

const svgComponent = shallowRef(null);

const loadSvg = async () => {
    const svgModule = await import(`@/assets/icons/${props.name}.svg`);
    svgComponent.value = svgModule.default;
}

onMounted(() => {
    loadSvg();
});

const iconStyle = computed(() => ({
    width: `${props.width}px`,
    height: `${props.height}px`,
    fill: props.color
}));
</script>

<template>
    <component :is="svgComponent" :style="iconStyle"></component>
</template>

<style lang="less" scoped>
    
</style>
